package com.share.device.api;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.device.constant.DeviceConstants;
import com.share.device.domain.StationVo;
import com.share.device.service.IDeviceService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 * @author ZhouShuang
 * @version 17
 * @Title
 * @date 2025/10/20 下午5:11
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/device")
public class DeviceApiController extends BaseController {


    private final IDeviceService deviceService;

    @Operation(summary = "根据当前位置的经纬度搜索附近门店")
    @GetMapping("/nearbyStation/{latitude}/{longitude}")
    public AjaxResult nearbyStation(@PathVariable String latitude, @PathVariable String longitude) {
        List<StationVo> stationVoList = deviceService.nearByStationList(latitude,longitude, DeviceConstants.SEARCH_PC_RADIUS);
        return success(stationVoList);
    }

    /**
     * 根据id获取门店详情
     * @param id
     * @param latitude
     * @param longitude
     * @return
     */
    @Operation(summary = "根据id获取门店详情")
    @GetMapping("/getStation/{id}/{latitude}/{longitude}")
    public AjaxResult getStation(@PathVariable Long id,@PathVariable String latitude,@PathVariable String longitude) {
        StationVo stationVo = deviceService.getStation(id,latitude,longitude);
        return success(stationVo);
    }
}
